home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _D238C9BD0E024360AB6628E67197A6F9 < prev    next >
Encoding:
Text File  |  2004-01-06  |  3.0 KB  |  105 lines

  1. Script:ReloadScript( "SCRIPTS/Default/Entities/AI/MutantRear_x.lua");
  2. MutantRear=CreateAI(MutantRear_x)
  3. ------------------------------------------------------------------------------------
  4.  
  5. -- activate mutant stealth
  6. function MutantRear:GoRefractive()
  7.     -- for some reason, this is called lots of times
  8.     if(self.isRefractive~=1) then                    
  9.         self.refractionSwitchDirection = 1;    
  10.         self.refractionValue = 0.15;    
  11.         self.isRefractive=1;
  12.         self.iPlayerEffect=5;            
  13.         
  14.         AI:Signal(SIGNALID_READIBILITY, 1, "VISIBLE_TO_REFRACTIVE",self.id);                
  15.                 
  16.     end        
  17. end
  18.  
  19. -- deactivate mutant stealth
  20. function MutantRear:GoVisible()    
  21.     -- for some reason, this is being called lots of times
  22.     --if(self.refractionSwitchDirection~=2 and self.isRefractive==1) then
  23.         
  24.         self.refractionSwitchDirection = 2;
  25.         -- died, go visible
  26.         if (self.cnt.health < 1) then    
  27.             self:ResetStealth();                
  28.         end                
  29.  
  30.         AI:Signal(SIGNALID_READIBILITY, 1, "REFRACTIVE_TO_VISIBLE",self.id);                
  31.     --end
  32. end
  33.  
  34. -- dehactivate stealth when entity gets damage
  35. function MutantRear:OnDamageCustom()    
  36.     self:GoVisible();
  37. end
  38.  
  39. -- update stealth
  40. function MutantRear:Client_OnTimerCustom()            
  41.     -- no stealth ?
  42.     if(self.refractionSwitchDirection==0) then
  43.         return nil;    
  44.     end 
  45.     
  46.     if(self.cnt.health < 1) then                        
  47.         self:ResetStealth();                    
  48.          return nil;
  49.     end    
  50.                                                 
  51.     -- set stealth
  52.     self.isRefractive=1;        
  53.             
  54.     --stealth not active ?
  55.     --if(self.iPlayerEffect~=5 and ClientStuff and ClientStuff.vlayers and not ClientStuff.vlayers:IsActive("HeatVision"))then                                  
  56.         self.iPlayerEffect=5;        
  57.     --end    
  58.         
  59.     -- go invisible
  60.     if(self.refractionSwitchDirection==1) then        
  61.         -- interpolate refraction amount
  62.         local    refrLimit =.01;
  63.         self.refractionValue= self.refractionValue+(refrLimit-self.refractionValue)*_frametime*50;
  64.                                         
  65.         -- clamp to refraction minimum limit
  66.         if( self.refractionValue<refrLimit+0.01 ) then
  67.             self.refractionValue = refrLimit;                            
  68.         end    
  69.     elseif(self.refractionSwitchDirection==2) then -- go visible
  70.         -- interpolate refraction amount
  71.         local    refrLimit =0.15;
  72.         self.refractionValue= self.refractionValue+(refrLimit-self.refractionValue)*_frametime*50;
  73.                                     
  74.         -- reset state
  75.         if(self.refractionValue>refrLimit-0.01 ) then
  76.             self.refractionValue = refrLimit;
  77.             self:ResetStealth();            
  78.         end
  79.     end        
  80.     
  81.     -- update refraction shader value
  82.     self:SetShaderFloat("Refraction", self.refractionValue, 0, 1);                    
  83. end
  84.  
  85. -- reset states
  86. function MutantRear:OnResetCustom()                                
  87.     if (self.Properties.fileBackpackModel) then
  88.         self:LoadObject( self.Properties.fileBackpackModel,1,0);
  89.         self:AttachObjectToBone( 1, "Bip01 Spine2" );    
  90.     end    
  91.  
  92.     self:GoRefractive();
  93. end 
  94.  
  95. function MutantRear:ResetStealth()
  96.  
  97.     -- reset shader            
  98.     --if(ClientStuff and ClientStuff.vlayers and not ClientStuff.vlayers:IsActive("HeatVision")) then    
  99.         self.iPlayerEffect=1;
  100.     --end    
  101.         
  102.     self.refractionSwitchDirection = 0;
  103.     self.refractionValue = 0.15;            
  104.     self.isRefractive=0;        
  105. end